import React, { Component } from 'react'
import './App.css'
export default class App extends Component {
    state = {
        index:3
    }
    changeIndex(index){
        this.setState({
            index
        })
    }
    render() {
        let {index} = this.state;
        return (
            <div className="box">
                <button className={index===1 ? 'active' : ''} onClick={()=>this.changeIndex(1)}>一楼</button>
                <button className={index===2 ? 'active' : ''} onClick={()=>this.changeIndex(2)}>二楼</button>
                <button className={index===3 ? 'active' : ''} onClick={()=>this.changeIndex(3)}>三楼</button>
                <div className={index===1 ? 'active' : ''}>
                    一楼
                </div>
                <div className={index===2 ? 'active' : ''}>
                    二楼
                </div>
                <div className={index===3 ? 'active' : ''}>
                    三楼
                </div>
            </div>
        )
    }
}
